package com.hey.bigservice.redis.controller;

import com.hey.bigservice.redis.config.DistributedLocker;
import com.hey.bigservice.redis.config.MyConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    MyConfig myConfig;

    @Autowired
    DistributedLocker locker;

    public static String a = "";

    @GetMapping("/get")
    public String get() throws InterruptedException {
        String key = "key_a";
        System.out.println(locker.lock(key));
        a = "修改了";

//        redisLock.unlock(key);
        System.out.println("程序端口号为："+myConfig.getPort());
        Thread.sleep(5000L);
        return a;
    }
}
